﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 第六章
{
    public partial class _6__2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<string> str = new List<string>();

            //获取主机名
            string hostName = Dns.GetHostName();

            //返回所有地址
            IPAddress[] addressesList = Dns.GetHostAddresses(hostName);
            foreach (IPAddress ip in addressesList)
            {
                string _temp_ip = ip.MapToIPv4().ToString();
                string[] ipstr = _temp_ip.Split('.');
                if (ipstr[0] == "218" && ipstr[1] == "75")
                {
                    Label1.Text = "来访者IP地址：" + _temp_ip + "<br/>";
                }
                else
                {
                    Label2.Text = "非法用户！即将结束访问";
                    Response.Write("<script>alert('非法用户！即将结束访问');window.close();</script>");
                }
            }



        }
    }
}